<?php
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
					"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv='content-type' content='text/html; charset=utf-8' />
		<title>Forum project</title>
		<link href="css/default.css" rel="stylesheet" type="text/css" />		
		<script type='text/javascript' language='javascript'>
			djConfig = {
				isDebug: true,
				bindEncoding: "utf-8"
			};
		</script>
		<script type='text/javascript' language='javascript' src='dojo/dojo.js'></script>
		<script type='text/javascript' language='javascript' src="js/cookies.js"></script>
		<script type='text/javascript' language='javascript'>
			dojo.require("dojo.io.*");
			dojo.require("dojo.event.*");
			dojo.require("dojo.rpc.*");
			dojo.require("dojo.rpc.JsonService");
			
			var usersObject = null;
			var forumObject = null;
			
			dojo.addOnLoad(function() {
			     var logoutbut=dojo.byId("logoutbutton");
			     logoutbut.style.display='none';
              var formular=dojo.byId('regForm');
           formular.style.display='none';			
							var registerButton = dojo.byId('registerButton');
				dojo.event.connectOnce(registerButton, 'onclick', 'register');
				usersObject = smd("Users");
				//forumObject = smd("Forum");
			})
			
			function smd(className) {
				return new dojo.rpc.JsonService("../server/services/index.php?class="+className);
			}
			
			function register() {
				var loginName = dojo.byId('loginName');
				var loginPasswd = dojo.byId('loginPasswd');
				var loginPasswdRepeat = dojo.byId('loginPasswdRepeat');
				
				loginName = loginName.value;
				loginPasswd = loginPasswd.value;
				loginPasswdRepeat = loginPasswdRepeat.value;
				
				var myDeffered = usersObject.register(loginName, loginPasswd, loginPasswdRepeat);
				myDeffered.addCallback("res");
				myDeffered.addErrback("errback");
			}
			
			function errback(result) {
				dojo.debugShallow(result.error);
			}
			
			function res(SLON) {
                               	dojo.debugShallow(SLON);
				if (!SLON.result) {
					alert(SLON.message);
                                  
				}
				else {
					
				}
			}
			
			function showForm(){
           var formular=dojo.byId('regForm');
           formular.style.display='';			
			}
		</script>
	</head>
	<body>
     <div id="header">
	<div id="logo">
		<h1><a href="#">Kurva, Bezadis!!!<sup></sup></a></h1>
		<h2>Designed by ja</h2>
	</div>
	<div id="menu">
		<ul>
			<li class="active" id='loginbutton'>
			<a href="#" >login</a></li>
			<li id='regsiterbutton'><a href="#" onclick='showForm()'>register</a></li>
			<li id='logoutbutton'><a href="#">logout</a></li>
		</ul>
	</div>
</div>
<!-- end header -->

<!-- start page -->
<div id="page">
	<!-- start content -->
	<div id="content">
   <div class='post' id='regForm'>		
      <h2 class='title'><b><center>Registration form</center></b></h2>		
       <div class='entry'>		
        <center>		
		<form onsubmit='return false;' action='.' method='post' id='myForm'>
			<table>
        <tr>			
			<td><label for='loginName'>Name: </label></td>
         <td><input type='text' id='loginName' name='loginName' /></td> 
          </tr><tr>
          <td>
          <label for='loginPasswd'>Password: </label>
          </td>
          <td><input type='password' id='loginPasswd' name='loginPasswd' /></td>
          <tr>			
           <td><label for='loginPasswdRepeat'>Repeat password: </label></td>			
			<td><input type='password' id='loginPasswdRepeat' name='loginPasswdRepeat' /></td>
			</tr>
			</table>
			<input type='submit' id='registerButton' name='registerButton' value='Register' />
		</form>
		</center>
		</div>
		<div class='entry'>
		</div>
		
		</div>

	<div style="clear: both;">&nbsp;</div>
</div>
<div id="footer">
	<div id="footer-menu">
		<ul>
			<li class="active"><a href="#">napriklad nas</a></li>
		</ul>
	</div>
	<p>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>

	</body>
</html>